package game;

import java.awt.Color;

public class Bullet extends AbstractMovingSprite {

	private float speed = 0.5f;
	
	
	private Bullet(int x, int y, int width, int height, Color color) {
		super(x, y, width, height, color);
	}
	
	public static Bullet createBulletFor(Player player) {
		
		int x = player.getX() + (player.getWidth() / 2), y = player.getY() + (player.getHeight() / 2);
		if (player.getHorizontalShootingDirection() == Direction.LEFT) {
			x = player.getX() - 5;
		}
		else if (player.getHorizontalShootingDirection() == Direction.RIGHT) {
			x = player.getX1() + 1;
		}
		
		if (player.getVerticalShootingDirection() == Direction.UP) {
			y = player.getY() - 5;
		}
		else if (player.getVerticalShootingDirection() == Direction.DOWN) {
			y = player.getY1() + 1;
		}
		
		Bullet bullet = new Bullet(x, y, 4, 4, player.getColor());
		bullet.setHorizontalDirection(player.getHorizontalShootingDirection());
		bullet.setVerticalDirection(player.getVerticalShootingDirection());
		
		return bullet;
		
		
	}
	

	@Override
	public float getSpeed() {
		return speed;
	}

}
